home *** CD-ROM | disk | FTP | other *** search
- /* Socket headers for MacSocket calls*/
-
- #pragma once
-
- struct hostent {
- char *h_name; /*official name of host*/
- char **h_aliases; /*alias list*/
- long h_addrtype; /*host address type*/
- long h_length; /*length of address*/
- char **h_addr_list; /*list of addresses from nameserver*/
- #define h_addr h_addr_list[0] /* address, for backward compatiblity */
- };
-
- struct servent {
- char *s_name; /* official service name */
- char **s_aliases; /* alias list */
- long s_port; /* port # */
- char *s_proto; /* protocol to use */
- };
-
-
-
- typedef unsigned short u_short;
- typedef unsigned long u_int;
- typedef unsigned long u_long;
- typedef unsigned char u_char;
- typedef long fd_mask;
-
- struct in_addr {
- u_long s_addr;
- };
-
- struct sockaddr {
- u_short sa_family; /*address family*/
- char sa_data[14]; /*up to 14 bytes of direct address*/
- };
-
- struct sockaddr_in {
- short sin_family;
- u_short sin_port;
- struct in_addr sin_addr;
- char sin_zero[8];
- };
-
- struct timeval {
- long tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
- };
-
-
- #define NBBY 8L
- #define NFDBITS (sizeof(fd_mask) * NBBY)
- #define howmany(x, y) (((x)+((y)-1L))/(y))
- #define CHANNELSIZE 16L /* Size of a channel */
- #define FD_SETSIZE 512L
-
- typedef struct fd_set {
- fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
- } fd_set;
-
- #define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
- #define FD_SET(n, p) ((p)->fds_bits[(n)/CHANNELSIZE/NFDBITS] |= (1L << (((n)/CHANNELSIZE) % NFDBITS)))
- #define AF_INET 0L
- #define SOCK_STREAM 0L
- #define NUM_SOCKETS 32L
- #define BUFF_SIZE 8192L
-
-
-
- long connect (long s, struct sockaddr *name, long namelen);
- struct hostent *gethostbyname (char *name);
- struct servent *getservbyname(char *name, char *proto);
- long recv (long s, char *buf, long len, long flags);
- long send (long s, char *msg, long len, long flags);
- long socket (long af, long type, long protocol);
- long shutdown (long s, long how);
- long socket_close (long s);
- void bzero(void *s, long size);
- unsigned short htons(unsigned short hostshort);
- int s_select( long nfds, long *readfds, long *writefds,
- long *exceptfds, struct timeval *timeout);
-
- /*
- * Error codes
- */
-
- #define EPERM 1 /* Not owner */
- #define ENXIO 6 /* No such device or address */
- #define E2BIG 7 /* Arg list too long */
- #define ENOEXEC 8 /* Exec format error */
- #define ECHILD 10 /* No children */
- #define EAGAIN 11 /* No more processes */
- #define ENOMEM 12 /* Not enough core */
- #define EFAULT 14 /* Bad address */
- #define ENOTBLK 15 /* Block device required */
- #define EXDEV 18 /* Cross-device link */
- #define EISDIR 21 /* Is a directory */
- #define ENOTTY 25 /* Not a typewriter */
- #define ETXTBSY 26 /* Text file busy */
- #define EFBIG 27 /* File too large */
- #define ESPIPE 29 /* Illegal seek */
- #define EMLINK 31 /* Too many links */
- #define EPIPE 32 /* Broken pipe */
-
- /* math software */
-
- /* non-blocking and interrupt i/o */
- #define EWOULDBLOCK 35 /* Operation would block */
- #define EDEADLK EWOULDBLOCK /* ditto */
- #define EINPROGRESS 36 /* Operation now in progress */
- #define EALREADY 37 /* Operation already in progress */
-
- /* ipc/network software */
-
- /* argument errors */
- #define ENOTSOCK 38 /* Socket operation on non-socket */
- #define EDESTADDRREQ 39 /* Destination address required */
- #define EMSGSIZE 40 /* Message too long */
- #define EPROTOTYPE 41 /* Protocol wrong type for socket */
- #define ENOPROTOOPT 42 /* Protocol not available */
- #define EPROTONOSUPPORT 43 /* Protocol not supported */
- #define ESOCKTNOSUPPORT 44 /* Socket type not supported */
- #define EOPNOTSUPP 45 /* Operation not supported on socket */
- #define EPFNOSUPPORT 46 /* Protocol family not supported */
- #define EAFNOSUPPORT 47 /* Address family not supported by proto
- col family */
- #define EADDRINUSE 48 /* Address already in use */
- #define EADDRNOTAVAIL 49 /* Can't assign requested address */
-
- /* operational errors */
- #define ENETDOWN 50 /* Network is down */
- #define ENETUNREACH 51 /* Network is unreachable */
- #define ENETRESET 52 /* Network dropped connection on reset *
- /
- #define ECONNABORTED 53 /* Software caused connection abort */
- #define ECONNRESET 54 /* Connection reset by peer */
- #define ENOBUFS 55 /* No buffer space available */
- #define EISCONN 56 /* Socket is already connected */
- #define ENOTCONN 57 /* Socket is not connected */
- #define ESHUTDOWN 58 /* Can't send after socket shutdown */
- #define ETOOMANYREFS 59 /* Too many references: can't splice */
- #define ETIMEDOUT 60 /* Connection timed out */
- #define ECONNREFUSED 61 /* Connection refused */
-
- /* */
- #define ELOOP 62 /* Too many levels of symbolic links */
- #define ENAMETOOLONG 63 /* File name too long */
-
- /* should be rearranged */
- #define EHOSTDOWN 64 /* Host is down */
- #define EHOSTUNREACH 65 /* No route to host */
- #define ENOTEMPTY 66 /* Directory not empty */
-
- /* quotas & mush */
- #define EPROCLIM 67 /* Too many processes */
- #define EUSERS 68 /* Too many users */
- #define EDQUOT 69 /* Disc quota exceeded */
-
- #define EVMSERR 65535 /* VMS-specific error code for non-translatable
- errors from VMS to C */
-
-
-
-